"""TODO header

Based on https://developers.google.com/appengine/docs/python/tools/localunittesting#Setting_Up_a_Testing_Framework.

Requires python 2.7 for unittest (or python < 2.7 and unittest2, though I
personally haven't tried that).
"""

import optparse
import sys
import unittest

USAGE = """%prog SDK_PATH HOTPOTATO_PATH
Run tests for Hot Potato.

SDK_PATH    Path to the SDK installation
HOTPOTATO_PATH    Path to Hot Potato app root"""


def main(sdk_path, hotpotato_path):
    sys.path.insert(0, sdk_path)
    import dev_appserver
    dev_appserver.fix_sys_path()
    suite = unittest.loader.TestLoader().discover(hotpotato_path)
    unittest.TextTestRunner(verbosity=2).run(suite)


if __name__ == '__main__':
    parser = optparse.OptionParser(USAGE)
    options, args = parser.parse_args()
    if len(args) != 2:
        print 'Error: Exactly 2 arguments required.'
        parser.print_help()
        sys.exit(1)
    SDK_PATH = args[0]
    HOTPOTATO_PATH = args[1]
    main(SDK_PATH, HOTPOTATO_PATH)
